<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
    <script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
    <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    <style>
        .item img{
            width:140px;
            height:140px;
        }
        *{margin:0;padding:0}
        .item{
            border:1px solid #eee;
            border-radius: 15px;
            float: left;
            padding:20px;
            margin-top:10px;
        }
        .app{
            width:980px;
            /* border:1px solid #666; */
            margin-left: auto;
            margin-right: auto;
            overflow: hidden;
        }
        .item:not(:nth-child(5n+5)){
            margin-right: 17px;
        }
    </style>
</head>

<body>
    <div id="app">

    </div>
    <!-- jsx -->
    <script type="text/babel">
        class Hello extends React.Component{
            constructor(props){
                super(props)
                this.state = {
                    msg:"你好",
                    arr:[]
                }
            }
            render(){
                return (
                    <div className="app">
                        {this.state.arr.map((item,index)=>{
                            return (<div key={index} className="item"> 
                           
                                <img src={item.coverImgUrl}/>
                                <p>{item.name.slice(0,5)+"..."}</p>
                            </div>)
                        })}
                    </div>)
            }
            componentDidMount(){
                var url = "https://music.aityp.com/top/playlist/?cat=日语&limit=20"
                $.ajax({
                    url,
                    success:res=>{
                        this.setState({
                            arr:res.playlists
                        })
                    }
                })
            }
        }
        ReactDOM.render(
            <Hello/>,
            document.getElementById("app")
        )
    </script>
</body>

</html>